/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.DealManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ 
/*    */ public class AddDeal extends AbstractAddUpdateCustomerDeal
/*    */ {
/* 21 */   private int id = 0;
/*    */ 
/*    */   public AddDeal(AbstractHttpServlet servlet) {
/* 24 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 31 */     User loginUser = super.getLoginUser(request);
/* 32 */     String userId = loginUser.userId;
/* 33 */     int companyId = loginUser.companyId;
/*    */ 
/* 35 */     int customerId = Util.getURLIntParameter(request
/* 36 */       .getParameter("customerId"));
/* 37 */     String customerName = Util.getURLParameter(request
/* 38 */       .getParameter("customerName"));
/* 39 */     int customerType = Util.getURLIntParameter(request
/* 40 */       .getParameter("customerType"));
/*    */ 
/* 42 */     String name = Util.getURLParameter(request.getParameter("dealName"));
/*    */ 
/* 44 */     String note = Util.getURLParameter(request.getParameter("background"));
/*    */ 
/* 46 */     float price = Util.getURLFloatParameter(request.getParameter("price"));
/* 47 */     float commission = Util.getURLFloatParameter(request
/* 48 */       .getParameter("commission"));
/*    */ 
/* 50 */     int categoryId = Util.getURLIntParameter(request
/* 51 */       .getParameter("categoryId"));
/*    */ 
/* 54 */     String responsibleUserId = Util.getURLParameter(request
/* 55 */       .getParameter("responsibleUserId"));
/*    */ 
/* 58 */     int visible = 1;
/* 59 */     String permissionsId = "";
/*    */ 
/* 62 */     if ((customerId <= 0) || (name == null) || (name.trim().length() == 0)) {
/* 63 */       response.sendRedirect(request.getContextPath() + "/deals/new");
/* 64 */       return;
/*    */     }
/*    */ 
/* 67 */     List extInfos = new ArrayList();
/*    */ 
/* 69 */     super.addFieldInfo(request, extInfos);
/*    */ 
/* 71 */     DealManager manager = new DealManager();
/*    */ 
/* 73 */     this.id = manager.add(customerId, customerName, customerType, 
/* 74 */       1, name, note, categoryId, responsibleUserId, 
/* 75 */       visible, permissionsId, price, commission, extInfos, companyId, 
/* 76 */       userId);
/* 77 */     if (this.id <= 0) {
/* 78 */       response.sendRedirect(request.getContextPath() + "/deals/");
/* 79 */       return;
/*    */     }
/*    */ 
/* 82 */     response.sendRedirect(request.getContextPath() + "/deals/" + this.id);
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.AddDeal
 * JD-Core Version:    0.6.1
 */